package view.toolboxComponents;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import controller.CustomEvent;
import controller.EventHandler;
import controller.ToolBoxEventHandler;
/** * A class to encapsulate the line colour panel for the designer * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
@SuppressWarnings("serial")
public class PrescriptionLineColourPanel extends AbstractPanel{
	private JLabel lblLineColour;
	private JButton btnLineColour;
	private EventHandler eventHandler;

	public PrescriptionLineColourPanel(){
		super();
		btnLineColour = new JButton();
		btnLineColour.setPreferredSize(new Dimension(12,12));
		btnLineColour.setMaximumSize(new Dimension(12,12));
		btnLineColour.setToolTipText("Line colour of object");
		lblLineColour = new JLabel("Line Colour");
		btnLineColour.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("presLineColourChange", PrescriptionLineColourPanel.this);
				PrescriptionLineColourPanel.this.eventHandler = new ToolBoxEventHandler();
				PrescriptionLineColourPanel.this.eventHandler.createEvent(event);
			}
		});
		buildPanel();
	}	/**	 * Sets the background colour of the button	 * @param c the {@link java.awt.Color} object to set the colour to.	 */
	public void setButtonBackgroundColour(Color c){
		btnLineColour.setBackground(c);
	}
	
	/**
	 * Build prescription name panel
	 */
	private void buildPanel() 
	{
		this.add(lblLineColour);
		makeRigidArea();
		this.add(btnLineColour);
	}
	public void resetComponent() 
	{
		btnLineColour.setBackground(null);	
	}
}